<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>编辑员工</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<style type="text/css">
			#sfz_pic{position: relative;}/*opacity: 0;*/
			 .upload,.upload1{position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0;}
		</style>
	</head>

	<body>
		<form class="layui-form update_form">
			<div class="layui-form-item">
				<label class="layui-form-label">参与人数</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="user_num" id="user_num"  placeholder="{$list['user_num']}" autocomplete="off" class="layui-input"  disabled="disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">鼓励金总额</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="gold_sum" id="gold_sum"   placeholder="{$list['gold_sum']}" autocomplete="off" class="layui-input"  disabled="disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">选择员工</label>
				<div class="layui-input-block update_shurk">
					<select name="clerk_id" id='clerk_id'>
						<option value="0">选择员工</option>
						{foreach name="emps" item="em"}
						<option value="{$em.id}">{$em.name}</option>
						{/foreach}
					</select>
				</div>
			</div>
			<input type='hidden' name='b_id' value="{$list['id']}">
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn"  lay-submit lay-filter="submit_from" type="button" >立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
</html>
<script>
	layui.use('form', function() {
		var form = layui.form;
		//监听表单提交
		form.on('submit(submit_from)', function(data){
			tijiao();
  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
	});
	
	function tijiao() {
		var clerk_id = $('#clerk_id').val();
		if(clerk_id ==0){
			layer.msg('请选择要编辑的员工');
			return;
		}
		
		$.ajax({
			type: "post",
			url: "{:url('activet/gold_update')}",
			data: $('.layui-form').serialize(), //表单数据
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function() {
						window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
						parent.layer.close(index);
					});
				} else {
					layer.msg(data.msg); //保存成功提示
					}
				},
				error: function(data) {
					var a = data;
				}
			});
	
	}
</script>
